package flc.ast.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.bean.StkResBean;

public class IconSelTabAdapter extends StkProviderMultiAdapter<StkResBean> {


    public IconSelTabAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new IconSelTabProvider());
    }

    private class IconSelTabProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_icon_sel;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(getContext()).load(bean.getUrl())
                    .into((ImageView) baseViewHolder.getView(R.id.ivIconSelItemImg));
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.ivIconSelItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivIconSelItemSel).setVisibility(View.INVISIBLE);
            }
        }
    }

}
